/*
	@file: log/include/LogDispatcher.h
	@author: Wolfhead
 */
#ifndef _LOG_LOG_DISPATCHER_H_
#define _LOG_LOG_DISPATCHER_H_


#include "LogRunner.h"
#include "LogPriority.h"
#include "logger/Logger.h"
#include "formatter/Formatter.h"
#include "LogOption.h"
#include "LogData.h"

namespace logger
{

class LogDispatcher
	: public boost::noncopyable
{
public:

	LogDispatcher();
	~LogDispatcher();

	int add_logger(
		const std::string& name, 
		const LogOption& option
	);

	int start_logger(
		const std::string& name
		);

	int start_all();
	
	int delete_logger(
		const std::string& name);

	int get_logger_option(
		const std::string& name,
		LogOption& option);

	int set_logger_option(
		const std::string& name,
		const LogOption& option);

	int log(LogDataPtr data_ptr); 

	int get_aggregate_priority();

private:

	// compute the aggregate priority of all
	// runner in this dispatcher
	int compute_priority();

	std::map<std::string/*name*/, LogRunnerPtr> m_name_map;
	std::vector<LogRunnerPtr> m_runner;

	LogPriority m_aggregate_priority;

	boost::shared_mutex m_mutex;
};


} //namespace logger


#endif
